package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.TransferAccountsPeopleAddDTO;
import org.jsola.hr.dto.TransferAccountsPeopleUpdateDTO;
import org.jsola.hr.entity.TransferAccountsPeopleDO;
import org.jsola.hr.query.TransferAccountsPeopleQuery;
import org.jsola.hr.service.ITransferAccountsPeopleService;
import org.jsola.hr.vo.TransferAccountsPeopleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账人员库
 *
 * @author zhr
 */
@Component
public class TransferAccountsPeopleTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsPeopleService transferAccountsPeopleService;

    /**
     * 生成add测试数据
     * @return TransferAccountsPeopleAddDTO
     */
    public TransferAccountsPeopleAddDTO getTransferAccountsPeopleAddDTO(){
        TransferAccountsPeopleAddDTO transferAccountsPeopleAddDTO = new TransferAccountsPeopleAddDTO();
        transferAccountsPeopleAddDTO.setCompanyId(getRandomValue("varchar",32));
        transferAccountsPeopleAddDTO.setPhone(getRandomValue("varchar",20));
        transferAccountsPeopleAddDTO.setAvatar(getRandomValue("varchar",500));
        transferAccountsPeopleAddDTO.setName(getRandomValue("varchar",20));
        transferAccountsPeopleAddDTO.setNickName(getRandomValue("varchar",100));
        transferAccountsPeopleAddDTO.setIdCard(getRandomValue("varchar",20));
        transferAccountsPeopleAddDTO.setOpeningBank(getRandomValue("varchar",20));
        transferAccountsPeopleAddDTO.setZfbIdentity(getRandomValue("varchar",64));
        transferAccountsPeopleAddDTO.setIsZfbBinding(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsPeopleAddDTO.setVxIdentity(getRandomValue("varchar",64));
        transferAccountsPeopleAddDTO.setIsVxBinding(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsPeopleAddDTO.setBankIdentity(getRandomValue("varchar",64));
        transferAccountsPeopleAddDTO.setIsBankBinding(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsPeopleAddDTO.setIsPingAnBank(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsPeopleAddDTO.setIsOthArea(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsPeopleAddDTO.setRemark(getRandomValue("varchar",255));
        transferAccountsPeopleAddDTO.setIdCardUrl(getRandomValue("varchar",500));
        transferAccountsPeopleAddDTO.setBankCardUrl(getRandomValue("varchar",500));
        return transferAccountsPeopleAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsPeopleUpdateDTO
     */
    public TransferAccountsPeopleUpdateDTO getTransferAccountsPeopleUpdateDTO(TransferAccountsPeopleVO transferAccountsPeopleVO){
        return transferAccountsPeopleService.selectDOById(transferAccountsPeopleVO.getId(), SITE_ID).to(TransferAccountsPeopleUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsPeopleQuery
     */
    public TransferAccountsPeopleQuery getTransferAccountsPeopleQuery() {
        TransferAccountsPeopleQuery transferAccountsPeopleQuery = new TransferAccountsPeopleQuery();
        List<TransferAccountsPeopleDO> transferAccountsPeopleDOList = transferAccountsPeopleService.list(new TransferAccountsPeopleDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsPeopleDOList)) {
            TransferAccountsPeopleDO transferAccountsPeopleDO = transferAccountsPeopleDOList.get(0);
            transferAccountsPeopleQuery = transferAccountsPeopleDO.to(TransferAccountsPeopleQuery.class);
        }
        return transferAccountsPeopleQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsPeopleVO
     */
    public TransferAccountsPeopleVO saveTransferAccountsPeopleExample(){
        TransferAccountsPeopleAddDTO addDTO = this.getTransferAccountsPeopleAddDTO();
        TransferAccountsPeopleVO transferAccountsPeopleVO = transferAccountsPeopleService.save(addDTO,buildTokenUser());
        return transferAccountsPeopleVO;
    }


}

